M= [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],\
    [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],\
    [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],\
    [3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3],\
    [3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3],\
    [3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3],\
    [3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3],\
    [3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3],\
    [3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3],\
    [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],\
    [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],\
    [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]

#| Plan du jeu :
#| 3  0 0 0 0 0 0 0
#| 4  0 0 0 0 0 0 0
#| 5  0 0 0 0 0 0 0
#| 6  0 0 0 0 0 0 0
#| 7  0 0 0 0 0 0 0
#| 8  0 0 0 0 0 0 0
#| XX 3 3 3 3 3 3 3
#| XX 3 4 5 6 7 8 9

col=[3,4,5,6,7,8,9]
lig=[3,4,5,6,7,8]
colonne=0
ligne=0

def jouer1():
    colonne=eval(input("Quelle colonne ?"))
    ligne=eval(input("Quelle ligne ?"))
    M[colonne][ligne]=1
    #Test horizontal
    if (M[colonne][ligne]==M[colonne+1][ligne] and M[colonne][ligne]==M[colonne+2][ligne] and M[colonne][ligne]==M[colonne+3][ligne]) or (M[colonne][ligne]==M[colonne-1][ligne] and M[colonne][ligne]==M[colonne+1][ligne] and M[colonne][ligne]==M[colonne+2][ligne]) or (M[colonne][ligne]==M[colonne-2][ligne] and M[colonne][ligne]==M[colonne-1][ligne] and M[colonne][ligne]==M[colonne+1][ligne]) or (M[colonne][ligne]==M[colonne-3][ligne] and M[colonne][ligne]==M[colonne-2][ligne] and M[colonne][ligne]==M[colonne-3][ligne]):
        test=1
    #Test vertical
    elif (M[colonne][ligne]==M[colonne][ligne+1] and M[colonne][ligne]==M[colonne][ligne+2] and M[colonne][ligne]==M[colonne][ligne+3]) or (M[colonne][ligne]==M[colonne][ligne-1] and M[colonne][ligne]==M[colonne][ligne+1] and M[colonne][ligne]==M[colonne][ligne+2]) or (M[colonne][ligne]==M[colonne][ligne-2] and M[colonne][ligne]==M[colonne][ligne-1] and M[colonne][ligne]==M[colonne][ligne+1]) or (M[colonne][ligne]==M[colonne][ligne-1] and M[colonne][ligne]==M[colonne][ligne-2] and M[colonne][ligne]==M[colonne][ligne-3]):
        test=1
    #Test diagonal /
    elif (M[colonne][ligne]==M[colonne+1][ligne+1] and M[colonne][ligne]==M[colonne+2][ligne+2] and M[colonne][ligne]==M[colonne+3][ligne+3]) or (M[colonne][ligne]==M[colonne-1][ligne-1] and M[colonne][ligne]==M[colonne+1][ligne+1] and M[colonne][ligne]==M[colonne+2][ligne+2]) or (M[colonne][ligne]==M[colonne-2][ligne-2] and M[colonne][ligne]==M[colonne-1][ligne-1] and M[colonne][ligne]==M[colonne+1][ligne+1]) or (M[colonne][ligne]==M[colonne-1][ligne-1] and M[colonne][ligne]==M[colonne-2][ligne-2] and M[colonne][ligne]==M[colonne-3][ligne-3]):
        test=1
    #Test diagonal \
    elif (M[colonne][ligne]==M[colonne-1][ligne+1] and M[colonne][ligne]==M[colonne-2][ligne+2] and M[colonne][ligne]==M[colonne-3][ligne+3]) or (M[colonne][ligne]==M[colonne+1][ligne-1] and M[colonne][ligne]==M[colonne-1][ligne+1] and M[colonne][ligne]==M[colonne-2][ligne+2]) or (M[colonne][ligne]==M[colonne+2][ligne-2] and M[colonne][ligne]==M[colonne+1][ligne-1] and M[colonne][ligne]==M[colonne-1][ligne+1]) or (M[colonne][ligne]==M[colonne+1][ligne-1] and M[colonne][ligne]==M[colonne+2][ligne-2] and M[colonne][ligne]==M[colonne+3][ligne-3]):
        test=1
    print(M)


def jouer2():
    colonne=eval(input("Quelle colonne ?"))
    ligne=eval(input("Quelle ligne ?"))
    M[colonne][ligne]=2
    #Test horizontal
    if (M[colonne][ligne]==M[colonne+1][ligne] and M[colonne][ligne]==M[colonne+2][ligne] and M[colonne][ligne]==M[colonne+3][ligne]) or (M[colonne][ligne]==M[colonne-1][ligne] and M[colonne][ligne]==M[colonne+1][ligne] and M[colonne][ligne]==M[colonne+2][ligne]) or (M[colonne][ligne]==M[colonne-2][ligne] and M[colonne][ligne]==M[colonne-1][ligne] and M[colonne][ligne]==M[colonne+1][ligne]) or (M[colonne][ligne]==M[colonne-3][ligne] and M[colonne][ligne]==M[colonne-2][ligne] and M[colonne][ligne]==M[colonne-3][ligne]):
        test=1
    #Test vertical
    elif (M[colonne][ligne]==M[colonne][ligne+1] and M[colonne][ligne]==M[colonne][ligne+2] and M[colonne][ligne]==M[colonne][ligne+3]) or (M[colonne][ligne]==M[colonne][ligne-1] and M[colonne][ligne]==M[colonne][ligne+1] and M[colonne][ligne]==M[colonne][ligne+2]) or (M[colonne][ligne]==M[colonne][ligne-2] and M[colonne][ligne]==M[colonne][ligne-1] and M[colonne][ligne]==M[colonne][ligne+1]) or (M[colonne][ligne]==M[colonne][ligne-1] and M[colonne][ligne]==M[colonne][ligne-2] and M[colonne][ligne]==M[colonne][ligne-3]):
        test=1
    #Test diagonal /
    elif (M[colonne][ligne]==M[colonne+1][ligne+1] and M[colonne][ligne]==M[colonne+2][ligne+2] and M[colonne][ligne]==M[colonne+3][ligne+3]) or (M[colonne][ligne]==M[colonne-1][ligne-1] and M[colonne][ligne]==M[colonne+1][ligne+1] and M[colonne][ligne]==M[colonne+2][ligne+2]) or (M[colonne][ligne]==M[colonne-2][ligne-2] and M[colonne][ligne]==M[colonne-1][ligne-1] and M[colonne][ligne]==M[colonne+1][ligne+1]) or (M[colonne][ligne]==M[colonne-1][ligne-1] and M[colonne][ligne]==M[colonne-2][ligne-2] and M[colonne][ligne]==M[colonne-3][ligne-3]):
        test=1
    #Test diagonal \
    elif (M[colonne][ligne]==M[colonne-1][ligne+1] and M[colonne][ligne]==M[colonne-2][ligne+2] and M[colonne][ligne]==M[colonne-3][ligne+3]) or (M[colonne][ligne]==M[colonne+1][ligne-1] and M[colonne][ligne]==M[colonne-1][ligne+1] and M[colonne][ligne]==M[colonne-2][ligne+2]) or (M[colonne][ligne]==M[colonne+2][ligne-2] and M[colonne][ligne]==M[colonne+1][ligne-1] and M[colonne][ligne]==M[colonne-1][ligne+1]) or (M[colonne][ligne]==M[colonne+1][ligne-1] and M[colonne][ligne]==M[colonne+2][ligne-2] and M[colonne][ligne]==M[colonne+3][ligne-3]):
        test=1
    print(M)

test=0
while test!=1:
    jouer1()
    jouer2()


